package PenTest.alibaba.ACM0415;

import java.util.*;

public class ACM1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String[] arr = sc.nextLine().split(" ");
        int[] arr1 = Arrays.stream(arr).mapToInt(Integer::parseInt).toArray();
        HashSet<Integer> set = new HashSet<>();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            set.add(arr1[i]);
        }
        for (int i = 0; i < N; i++) {
            map.put(arr1[i], map.getOrDefault(arr1[i], 0) + 1);
        }
        int ans = 0;
        int curr = 0;
        for (Integer i : map.keySet()) {
            curr=map.get(i);
            if (set.contains(i*2)||set.contains(i*2+1)) {
                if ((curr + 1) * 2 >= N) {
                    ans=Math.max(ans,i);
                }
            }
            if ((curr + 1) * 2 >= N) {
                ans=Math.max(ans,i);
            }
        }
        System.out.println(ans);
    }
}
